define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {

		//查询主校区和分校区
		httpService.post(app.urls.unit_selectSchoolAndAttach,{"fk_unit":"self"},function(data){
			if("0000" === data.code){
				$scope.unitList = data.data;
				$scope.selectById();
			}else{
				alert(data.msg);
			}
		});
		
		$scope.selectById = function(){
	    	httpService.post(app.urls.building_selectById,{"id":params.id},function(data){
				if("0000" === data.code){
					$scope.form= data.data;
					$scope.$apply();
				}else{
					alert(data.msg);
				}
			});
		}
		
		$scope.saveForm = function(){
			if($scope.formCheck()){

				httpService.post(app.urls.building_update,$scope.form,function(data){
					if("0000" === data.code){
						eventBusService.publish("content.page.reload", data);
						eventBusService.publish("modal.page.close", {});
		    		}else{
		    			alert(data.msg);
		    		}
				});
			}
		}
	
	
	}}});